package com.test.api.update.controller;

import com.alibaba.fastjson.JSON;
import com.test.constant.FunCodeConstant;
import com.test.message.Message;
import com.test.message.UpdatePackMessage;
import com.test.model.ConnectionManager;
import com.test.server.SyncFuture;

public class UpdateController {
    public static void main(String[] args) {
        String imei = "222222";

        SyncFuture<String> stringSyncFuture = new SyncFuture<>();

        UpdatePackMessage updatePackMessage = new UpdatePackMessage();
        updatePackMessage.setLength(11);


        Message message = new Message();
        message.setFunCode(FunCodeConstant.SERVER_UPGRADE.byteValue());
        message.setHead((short) 0xAA);

        byte[] bytes = JSON.toJSONBytes(updatePackMessage);
        message.setMessageLength((short) bytes.length);
        message.setMessageData(bytes);
        ConnectionManager.sendSyncMsg(stringSyncFuture, message, imei);
    }
}
